@extends('layouts.back_stage')
@section('style')
    @parent
    <link rel="stylesheet" type="text/css" href="/static/css/dealer.css"/>
@endsection
@section('content')
    <div class="reminder" style="position:absolute;top:60px;left:250px;z-index:1000;width:100%;height:100px;">
        <div style="width:550px;height:100px;float:left">
            <p style="height:20px;font-size:18px;">操作提示:</p>
            <p style="height:40px;line-height:40px;">请确保您的光标在输入框内且切换到英文输入法,然后用扫码枪依次扫描包装袋上的二维码.</p>
            <p style="height:20px;line-height:20px;">如有疑问请扫码咨询</p>
        </div>
        <img style="width:100px;height:100px;margin-left:100px" src="/img/vx.jpeg">
    </div>
    <div class="dealer">
        <div class="dealer_top">
            <div class="dealer_tl">
                <input type="text" class="dealer_inp" />
            </div>
            <dl class="dealer_dl">
                <dt class="dealer_dt"></dt>
                <dd class="dealer_dd"></dd>
            </dl>
        </div>
        <div class="dealer_bottom">
            <span class="dealer_span">信息:</span>
            <div class="dealer_bl">
                <p class="dealer_p p1">已收<i class="dealer_pass">0</i>手</p>
                <p class="dealer_p">剩余<b class="dealer_surplus">0</b>手</p>               
            </div>
            <div class="dealer_br">
                <ul class="dealer_ul">
                    <li class="dealer_li">
                        <span class="dealer_tit">品牌名称:</span>
                        <p class="dealer_brand dealer_mark"></p>
                    </li>
                    <li class="dealer_li">
                        <span class="dealer_tit">商品名称:</span>
                        <p class="dealer_brand dealer_name"></p>
                    </li>
                    <li class="dealer_li">
                        <span class="dealer_tit">指导售价:</span>
                        <p class="dealer_brand dealer_color"></p>
                    </li>
                    <li class="dealer_li">
                        <span class="dealer_tit">店铺信息:</span>
                        <p class="dealer_brand dealer_info"></p>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <div class="delDiv" style="display:none;">
        <div class="delDiv_tip"></div>        
        <div class="delDiv_info">	           	         
            <input id="btnDelTrue" type="button" value="确 认" class="btn-green" />	                  
        </div>
    </div>
    <div class="mask" style="display:none;"></div>
    <script>
    	
        //自动获取焦点
        setTimeout(function () {
            $(".dealer_inp").focus();
        },50);
        $(function(){
            $('.dealer_inp').blur(function () {
                var that = this;
                setTimeout(function () {
                    $(that).focus();
                },100);
            });
        });
        /*input实时监控*/
        $(".dealer_inp").on("input",function(){

           var old_dealer = $('.dealer_inp').val();
            if(old_dealer.length != 66){
                return false;
            }

            var dealer = old_dealer.substr(-32);

			$('.dealer_inp').val('');
            if (dealer != '') {
                $.ajax({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                    },
                    type: 'post',
                    url: '/dealer/confirmationOfGoods',
                    data: {'code':dealer},
                    dataType:'json',
                    success: function (data) {
                        if(data.msg=='Order_first'){//第一次扫码
                    		var arr1=data.info.produc_info;
                    		var arr2=data.info.bus_info;
	                    		$('.dealer_dt').html("<img src='https://{{ env('CDN_DOMAIN_NAME') }}/upload/"+arr1.img+"'/>");
	                    		$('.dealer_pass').text(arr1.all_count-arr1.surplus_count);
	                    		$('.dealer_surplus').text(arr1.surplus_count);
	                    		$('.dealer_mark').text(arr1.brand);	                    
	                    		$('.dealer_name').text(arr1.title);
	                    		$('.dealer_color').text("￥"+arr1.guidance_price);
	                    		$('.dealer_info').text(arr2.user_area+arr2.area_detail);
                    	}
                    	if(data.msg=='Order_repeat'){//重复扫码
                    		$('body').css("overflow","hidden");
                        	$('.dealer_inp').attr('readonly',true);
                        	$('.delDiv_tip').html('已扫过，请勿重复扫码!')
                        	$('.delDiv').show();
							$('.mask').show();
                    	}
                        if(data.msg=='不是本人扫码'){
                        	$('body').css("overflow","hidden");
                        	$('.dealer_inp').attr('readonly',true);
                        	$('.delDiv_tip').html('不是本人扫码!')
                        	$('.delDiv').show();
							$('.mask').show();
                        }
                        if(data.msg=='请扫描大码'){
                        	$('body').css("overflow","hidden");
                        	$('.dealer_inp').attr('readonly',true);
                        	$('.delDiv_tip').html('请扫大码!')
                        	$('.delDiv').show();
							$('.mask').show();
                        }
                        $('.dealer_inp').val('');                   
                    }
                })

            }


        })
        $(".btn-green").click(function(){
			$('body').css("overflow-y","scroll");
			$('.dealer_inp').attr('readonly',false);
        	$('.delDiv').hide();
			$('.mask').hide();
			setTimeout(function () {
			    $(".dealer_inp").focus();
			},50);
			$(function(){
				$('.dealer_inp').blur(function () {
					var that = this;
					setTimeout(function () {
						$(that).focus();
					},100);
				});
			});	
		})
    </script>
@endsection